
/*package com.hy.enterprise.framework.util.jpa ;

import java.io.IOException;
import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import javax.persistence.Entity;

//import org.jboss.seam.log.LogProvider;
//import org.jboss.seam.log.Logging;
//import org.scannotation.AnnotationDB;
//import org.scannotation.ClasspathUrlFinder;

*//**
 * <ul>
 * <li>设计作者：刘川</li>
 * <li>设计日期：2009-8-4</li>
 * <li>设计时间：下午01:13:05</li>
 * <li>设计目的：扫描Seam路径，并获取标注有@Entity注解的实体类的助手类</li>
 * </ul>
 * <ul>
 * <b>修订历史</b>
 * <li>1、</li>
 * </ul>
 *//*
public class EntityScanner
{
	*//**
	 * <ul>
	 * <li>设计作者：刘川</li>
	 * <li>设计日期：2009-8-4</li>
	 * <li>设计时间：下午01:15:27</li>
	 * <li>设计目的：延迟初始化控制器</li>
	 * </ul>
	 * <ul>
	 * <b>修订历史</b>
	 * <li>1、</li>
	 * </ul>
	 *//*
	private static class Holder
	{
		private static final EntityScanner	instance	=
		                                                  new EntityScanner ( ) ;
	}

	*//**
	 * 日志记录器
	 *//*
	private static final LogProvider	logger	=
	                                              Logging
	                                                     .getLogProvider ( EntityScanner.class ) ;
	*//**
	 * 默认资源名称数组
	 *//*
	private static String [ ]	     RESOURCES	=
	                                              {
	        "seam.properties" ,
	        "META-INF/seam.properties" ,
	        "META-INF/components.xml"
	                                              } ;

	*//**
	 * <ul>
	 * <li>设计作者：刘川</li>
	 * <li>设计日期：2009-8-4</li>
	 * <li>设计时间：下午01:15:55</li>
	 * <li>设计目的： 用于获取
	 * {@link com.vsoft.libra.enterprise.framework.util.jpa.EntityScanner}
	 * 类型实例的方法</li>
	 * </ul>
	 * <ul>
	 * <b>修订历史</b>
	 * <li>1、</li>
	 * </ul>
	 * 
	 * @return
	 *//*
	public static EntityScanner instance ( )
	{
		return Holder.instance ;
	}

	*//**
	 * 用于保存实体名称和实体类类型名称的集合
	 *//*
	protected final Map < String , String >	entities	=
	                                                      Collections
	                                                                 .synchronizedMap ( new HashMap < String , String > ( ) ) ;

	*//**
	 * 构造函数
	 *//*
	private EntityScanner ( )
	{
		super ( ) ;
	}

	*//**
	 * <ul>
	 * <li>设计作者：刘川</li>
	 * <li>设计日期：2009-8-4</li>
	 * <li>设计时间：下午01:19:41</li>
	 * <li>设计目的：实际扫描实体类的方法</li>
	 * </ul>
	 * <ul>
	 * <b>修订历史</b>
	 * <li>1、</li>
	 * </ul>
	 * 
	 * @throws ClassNotFoundException
	 *//*
	protected void scanEntities ( )
	                               throws ClassNotFoundException
	{
		for ( String resource : EntityScanner.RESOURCES )
		{
			try
			{
				URL [ ] urls =
				               ClasspathUrlFinder
				                                 .findResourceBases ( resource ) ;
				AnnotationDB annotationDB =
				                            new AnnotationDB ( ) ;
				annotationDB
				            .scanArchives ( urls ) ;
				Set < String > entityClasses =
				                               annotationDB
				                                           .getAnnotationIndex ( )
				                                           .get (
				                                                  Entity.class
				                                                              .getName ( ) ) ;
				if ( entityClasses != null )
				{
					for ( String className : entityClasses )
					{
						Class < ? > entityClass =
						                          Class
						                               .forName ( className ) ;
						Entity jpaAnnotation =
						                       entityClass
						                                  .getAnnotation ( Entity.class ) ;
						if ( jpaAnnotation != null )
						{
							String entityName =
							                    jpaAnnotation
							                                 .name ( ) ;
							if ( ( entityName == null )
							     || ( entityName
							                    .length ( ) == 0 ) )
							{
								entityName =
								             entityClass
								                        .getSimpleName ( ) ;
							}
							this.entities
							             .put (
							                    entityName ,
							                    entityClass
							                               .getName ( ) ) ;
						}
					}
				}
			}
			catch ( IOException ioException )
			{
				EntityScanner.logger
				                    .error (
				                             this ,
				                             ioException ) ;
			}
		}
	}

	*//**
	 * <ul>
	 * <li>设计作者：刘川</li>
	 * <li>设计日期：2009-8-4</li>
	 * <li>设计时间：下午01:16:50</li>
	 * <li>设计目的：获取给定名称实体类的类类型</li>
	 * </ul>
	 * <ul>
	 * <b>修订历史</b>
	 * <li>1、</li>
	 * </ul>
	 * 
	 * @param name
	 * @return
	 * @throws ClassNotFoundException
	 *//*
	public Class < ? > getEntity (
	                               String name )
	                                            throws ClassNotFoundException
	{
		if ( this.entities
		                  .isEmpty ( ) )
		{
			this
			    .scanEntities ( ) ;
		}

		return Class
		            .forName ( this.entities
		                                    .get ( name ) ) ;
	}
}*/
